﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    <script charset="utf-8" src="/resources/scripts/ajaxfileupload.js"></script>
}

@model AFT.Parking.Entity.FloorRecord
<div class="content-box">
    <!-- Content box header -->
    <div class="content-box-header clearfix">
        <h3>添加(编辑)楼层信息</h3>
    </div>

    <!-- Content box body -->
    <div class="content-box-content">
        <div class="tab-content default-tab" id="tab2">
            <form method="post" id="frm">
                <fieldset class="fieldset-floor-left">
                    <div>
                        <label>楼层平面图</label>
                        @{
                            var img = string.IsNullOrEmpty(Model.LayoutImg) ? "/resources/images/picture-model.png" : Model.LayoutImg;
                        }
                        <div class="upload">
                            <img id="fileImg" style="width: 120px; height: 120px;" src="@img" />
                            <input type="hidden" id="ImgShow" name="LayoutImg" value="@Model.LayoutImg" />
                            <button type="button" class="button" id="aFile">上传</button>
                        </div>
                    </div>
                </fieldset>

                <fieldset class="fieldset-floor-right">
                    @Html.Hidden("Id", Model.Id)
                    @Html.Hidden("TagId", Model.TagId)
                    @Html.Hidden("CreatorId", Model.CreatorId)
                    @Html.Hidden("CreateTime", Model.CreateTime)
                    <p>
                        <label>楼层名称</label>
                        @Html.TextBox("Name", Model.Name, new {@class = "text-input x-input"})
                    </p>

                    <p>
                        <label>楼栋编号</label>
                        @Html.TextBox("BuildingNo", Model.BuildingNo, new { @class = "text-input x-input" })
                    </p>

                    <div class="x-tab-item">
                        <p>
                            <label>二维码名称 (注：请保证二维码名称不一致，便于区分)</label>
                            @if (Model.Id > 0)
                            {
                                @Html.TextBox("TagName", Model.TagName, new {@class = "text-input x-input", @readonly = "readonly", style = "background: #E4E4E4;cursor:not-allowed"})
                            }
                            else
                            {
                                @Html.TextBox("TagName", Model.TagName, new {@class = "text-input x-input"})
                            }
                        </p>
                        <p class="x-btns">
                            <input class="button x-btn" type="submit" id="btnSubmit" value="&nbsp;保 存&nbsp;"/>
                            <input class="button x-btn" type="button" id="btnBack" value="&nbsp;返 回&nbsp;"/> <br/>
                            <span class="input-notification @ViewBag.Icon png_bg">@ViewBag.Message</span>
                            <input type="hidden" id="hd_backUrl" value="@Url.Action("List")">
                        </p>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>

<script>
    new AjaxUpload($("#aFile"), {
        action: '@Url.Action("UpLoadFile")',
        data: { folderName: "FloorRecordFile"},
        name: 'UploadImg',
        responseType: "json",
        onSubmit: function (file, extension) {
        },
        onComplete: function (file, data) {
            console.log(data);
            if (data.Value) {
                $("#fileImg").attr("src", data.Result[0]);
                $('#ImgShow').val(data.Result[0]);
            }
            else {
                alert("上传失败。");
            }
        }
    });
</script>

